package qldc.pm.tiensu.service.impl;

import java.util.Date;

import qldc.pm.tiensu.NoSuchPhieuThongTinVeNguoiCoTienSuException;
import qldc.pm.tiensu.model.PhieuThongTinVeNguoiCoTienSu;
import qldc.pm.tiensu.model.impl.PhieuThongTinVeNguoiCoTienSuImpl;
import qldc.pm.tiensu.service.base.PhieuThongTinVeNguoiCoTienSuLocalServiceBaseImpl;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;

/**
 * The implementation of the phieu thong tin ve nguoi co tien su local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are
 * added, rerun ServiceBuilder to copy their definitions into the
 * {@link qldc.pm.tiensu.service.PhieuThongTinVeNguoiCoTienSuLocalService}
 * interface.
 *
 * <p>
 * This is a local service. Methods of this service will not have security
 * checks based on the propagated JAAS credentials because this service can only
 * be accessed from within the same VM.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see qldc.pm.tiensu.service.base.PhieuThongTinVeNguoiCoTienSuLocalServiceBaseImpl
 * @see qldc.pm.tiensu.service.PhieuThongTinVeNguoiCoTienSuLocalServiceUtil
 */
public class PhieuThongTinVeNguoiCoTienSuLocalServiceImpl extends
		PhieuThongTinVeNguoiCoTienSuLocalServiceBaseImpl {
	public PhieuThongTinVeNguoiCoTienSu addPhieu(long tienSuId, long userId,
			String userName, String maSoHoSoTienSuTuToaAn,
			String nguoiTrichLuc, String thamPhan, String soDinhDanhCaNhan,
			String chuThich, String hoTenVoHoacChong, String hoTenCha,
			String hoTenMe, long noiThuongTruTinhId,
			long noiThuongTruQuanHuyenId, long noiThuongTruPhuongXaId,
			String noiThuongTruDiaChi, long noiTamTruTinhId,
			long noiTamTruQuanHuyenId, long noiTamTruPhuongXaId,
			String noiTamTruDiaChi) throws SystemException {
		long PhieuThongTinVeNguoiCoTienSuId = counterLocalService.increment(PhieuThongTinVeNguoiCoTienSu.class.getName());
		PhieuThongTinVeNguoiCoTienSu phieuThongTin =createPhieuThongTinVeNguoiCoTienSu(PhieuThongTinVeNguoiCoTienSuId);

		phieuThongTin.setUserId(userId);
		phieuThongTin.setUserName(userName);
		phieuThongTin.setCreateDate(new Date());
		phieuThongTin.setHoTenCha(hoTenCha);
		phieuThongTin.setHoTenMe(hoTenMe);
		phieuThongTin.setHoTenVoHoacChong(hoTenVoHoacChong);
		phieuThongTin.setTienSuId(tienSuId);
		phieuThongTin.setMaSoHoSoTienSuTuToaAn(maSoHoSoTienSuTuToaAn);
		phieuThongTin.setNguoiTrichLuc(nguoiTrichLuc);
		phieuThongTin.setThamPhan(thamPhan);
		phieuThongTin.setSoDinhDanhCaNhan(soDinhDanhCaNhan);
		phieuThongTin.setChuThich(chuThich);

		phieuThongTin.setNoiTamTruTinhId(noiTamTruTinhId);
		phieuThongTin.setNoiTamTruQuanHuyenId(noiTamTruQuanHuyenId);
		phieuThongTin.setNoiTamTruPhuongXaId(noiTamTruPhuongXaId);
		phieuThongTin.setNoiTamTruDiaChi(noiTamTruDiaChi);
		phieuThongTin.setNoiThuongTruTinhId(noiThuongTruTinhId);
		phieuThongTin.setNoiThuongTruQuanHuyenId(noiThuongTruQuanHuyenId);
		phieuThongTin.setNoiThuongTruPhuongXaId(noiThuongTruPhuongXaId);
		phieuThongTin.setNoiThuongTruDiaChi(noiThuongTruDiaChi);
		phieuThongTin = addPhieuThongTinVeNguoiCoTienSu(phieuThongTin);

		return phieuThongTin;
	}

	public PhieuThongTinVeNguoiCoTienSu updatePhieu(
			long phieuThongTinVeNguoiCoTienSuId, long tienSuId, long userId,
			String userName, String maSoHoSoTienSuTuToaAn,
			String nguoiTrichLuc, String thamPhan, String soDinhDanhCaNhan,
			String chuThich, String hoTenVoHoacChong,
			String hoTenCha, String hoTenMe, long noiThuongTruTinhId,
			long noiThuongTruQuanHuyenId, long noiThuongTruPhuongXaId,
			String noiThuongTruDiaChi, long noiTamTruTinhId,
			long noiTamTruQuanHuyenId, long noiTamTruPhuongXaId,
			String noiTamTruDiaChi) throws SystemException, PortalException {
		PhieuThongTinVeNguoiCoTienSu phieuThongTin = getPhieuThongTinVeNguoiCoTienSu(phieuThongTinVeNguoiCoTienSuId);

		phieuThongTin.setUserId(userId);
		phieuThongTin.setUserName(userName);
		phieuThongTin.setModifiedDate(new Date());

		phieuThongTin.setTienSuId(tienSuId);
		phieuThongTin.setMaSoHoSoTienSuTuToaAn(maSoHoSoTienSuTuToaAn);
		phieuThongTin.setHoTenCha(hoTenCha);
		phieuThongTin.setHoTenMe(hoTenMe);
		phieuThongTin.setHoTenVoHoacChong(hoTenVoHoacChong);
		phieuThongTin.setTienSuId(tienSuId);
		phieuThongTin.setNguoiTrichLuc(nguoiTrichLuc);
		phieuThongTin.setThamPhan(thamPhan);
		phieuThongTin.setSoDinhDanhCaNhan(soDinhDanhCaNhan);
		phieuThongTin.setChuThich(chuThich);
		phieuThongTin.setNoiTamTruTinhId(noiTamTruTinhId);
		phieuThongTin.setNoiTamTruQuanHuyenId(noiTamTruQuanHuyenId);
		phieuThongTin.setNoiTamTruPhuongXaId(noiTamTruPhuongXaId);
		phieuThongTin.setNoiTamTruDiaChi(noiTamTruDiaChi);
		phieuThongTin.setNoiThuongTruTinhId(noiThuongTruTinhId);
		phieuThongTin.setNoiThuongTruQuanHuyenId(noiThuongTruQuanHuyenId);
		phieuThongTin.setNoiThuongTruPhuongXaId(noiThuongTruPhuongXaId);
		phieuThongTin.setNoiThuongTruDiaChi(noiThuongTruDiaChi);
		
		phieuThongTin = updatePhieuThongTinVeNguoiCoTienSu(phieuThongTin);

		return phieuThongTin;
	}

	public PhieuThongTinVeNguoiCoTienSu findByMaHoSoToaAn(
			String maSoHoSoTienSuTuToaAn) {
		PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = null;

		try {
			phieuThongTinVeNguoiCoTienSu = phieuThongTinVeNguoiCoTienSuPersistence
					.findByMaSoHoSoTienSuTuToaAn(maSoHoSoTienSuTuToaAn);
		} catch (NoSuchPhieuThongTinVeNguoiCoTienSuException e) {
		} catch (SystemException e) {
		}

		return phieuThongTinVeNguoiCoTienSu;
	}

	public PhieuThongTinVeNguoiCoTienSu findByTienSuId(long tienSuId) {
		PhieuThongTinVeNguoiCoTienSu phieuThongTinVeNguoiCoTienSu = null;

		try {
			phieuThongTinVeNguoiCoTienSu = phieuThongTinVeNguoiCoTienSuPersistence
					.findByTienSuId(tienSuId);
		} catch (NoSuchPhieuThongTinVeNguoiCoTienSuException e) {
		} catch (SystemException e) {
		}

		return phieuThongTinVeNguoiCoTienSu;
	}
}
